#ifndef _PRODUCERIMPL_H_
#define _PRODUCERIMPL_H_

#include "stdafx.h"

#define TCP_CONSUMER_CONNECT 100

class CProducerImpl :	public  IProducer,
						public  IOperationEvent,
						public	CChannel,
						public	CUnknownImp
		
{
public:
	CProducerImpl(void);
	virtual ~CProducerImpl(void);

	BEGIN_STDCOM_MAP
		STDCOM_INTERFACE_ENTRY_UNKNOWN_(IProducer)
		STDCOM_INTERFACE_ENTRY(IOperationEvent)
		STDCOM_INTERFACE_ENTRY(IProducer)
	END_STDCOM_MAP

public:

	//IProducer
	std_method(SetId)(unsigned int id);
	std_method(Bind)(LPCSTR addr, int len);
	std_method(Close)();
	std_method(Send)(IBase* pBase);

	//IOperationEvent
	std_method(OnComplete)(IBase *pOperation, event_id event, ULONG error_code);
	
private:
	std_method(OnConnected)(IBase *pIBase);
	std_method(OnSendSeqed)(IBase *pIBase);
	std_method(OnRecvSeqAcked)(IBase *pIBase);
	std_method(OnSendAcked)(IBase *pIBase);
	std_method(OnSendHeaded)(IBase *pIBase);
	std_method(OnSended)(IBase *pIBase);
private:
	CSemHandle		m_sem;
	unsigned int	m_id;
};

#endif
